package com.czkt.springboot_mybatis_test.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.czkt.springboot_mybatis_test.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2024-06-18
 */
@Mapper
public interface ProductMapper extends BaseMapper<Product> {

    @Select("select count(*) from product where prod_name like concat('%',#{prodName},'%') and prod_type like concat('%',#{prodType},'%') and prod_batch like concat('%',#{prodBatch},'%')")
    Integer selectProductCount(@Param("prodName")String prodName,@Param("prodType") String prodType,@Param("prodBatch") String prodBatch);

    @Select("select * from product where prod_name like concat('%',#{prodName},'%') and prod_type like concat('%',#{prodType},'%') and prod_batch like concat('%',#{prodBatch},'%') limit #{pageIndex},#{pageSize}")
    List<Product> selectProduct(@Param("prodName")String prodName,@Param("prodType") String prodType,@Param("prodBatch") String prodBatch,@Param("pageIndex") Integer pageIndex,@Param("pageSize") Integer pageSize);

}
